package de.koller.so.render.logo;

import de.koller.oceanFramework.util.ColorIntUtil;
import java.awt.image.BufferedImage;

public class HeightMap {
	
	public final double map[][];
	
	public HeightMap( int w, int h ) {
		map = new double[ w ][ h ];
	}
	
	public BufferedImage getVisual() {
		double max = 1;
		double min = 0;
		
		for( int x = 0; x < map.length; x++ )
			for( int y = 0;  y < map[0].length; y++ ) {
				max = Math.max( max, map[x][y] );
				min = Math.min( min, map[x][y] );
			}
				
		
		BufferedImage i = new BufferedImage( map.length, map[0].length, BufferedImage.TYPE_INT_ARGB );
		for( int x = 0; x < map.length; x++ )
			for( int y = 0;  y < map[0].length; y++ ) {
				int v = (int)((map[x][y]-min) / (max-min) * 0xff);
				i.setRGB( x, y, ColorIntUtil.getIntColor( 0xff, v, v, v ) );
			}
		
		return i;
	}
	
}
